import 'package:flutter/material.dart';

class AnimatedPaddingView extends StatefulWidget {
  const AnimatedPaddingView({super.key});
  @override
  State<AnimatedPaddingView> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<AnimatedPaddingView> {
  bool flag = true;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        child: const Icon(Icons.animation),
        onPressed: () {
          setState(() {
            flag = !flag;
          });
        },
      ),
      appBar: AppBar(
        title: const Text("AnimatedContainer Demo"),
      ),
      body: AnimatedPadding(
        duration: const Duration(milliseconds: 2000), // 动画时长500 ms
        // curve: Curves.bounceInOut,
        //  curve: Curves.bounceOut,
        curve: Curves.bounceIn,
        padding: EdgeInsets.fromLTRB(10, flag ? 10 : 500, 0, 0),
        child: Container(
          width: 100,
          height: 100,
          color: Colors.red,
        ),
      ),
    );
  }
}
